<?php

namespace common\models\business;

use Yii;

/**
 * This is the model class for table "business_variety".
 *
 * @property string $id
 * @property string $title
 * @property string $parentid
 * @property integer $status
 */
class BusinessVariety extends \yii\db\ActiveRecord
{
    //主要用于日志记录
    public $uselog = [
        'tabcomment' => '仔猪品种',      //用于修改了什么的显示
        'mainfield' => 'title',      //主要的显示标题的字段
        'picturefield' => [],        //图片字段
        'timefield' => [],       //时间字段
        'unsetfiled' =>[],      //不需要记录的字段
    ];


    const CANLIVERY = 1;
    const NOTCANLIVERY = 0;
    public static $canlivery = [
        self::CANLIVERY => '可以领养',
        self::NOTCANLIVERY => '不可以领养'
    ];

    const INDEX = 1;
    const NOTINDEX = 0;
    public static $isindex = [
        self::NOTINDEX => '不推荐显示',
        self::INDEX => '推荐显示'
    ];


    const STATUS_SHOW = 1;
    const STATUS_HIDDEN = 0;
    public static $statues = [
        self::STATUS_SHOW => '启用',
        self::STATUS_HIDDEN => '不启用'
    ];



    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'business_variety';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['title'], 'required'],
            [['status','parentid','canlivery','isindex'], 'integer'],
            [['title','quality'], 'string', 'max' => 255],
            [['descripation'], 'safe'],
            [['picture'], 'image', 'extensions' => 'jpg, jpeg, gif, png', 'on' => ['insert', 'update']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => '名称',
            'parent' => '上级',
            'status' => '状态',
            'descripation' => '简介',
            'quality' => '品质说明',
            'canlivery' => '是否可以领养',
            'isindex' => '是否推荐',
            'picture' => '图片'
        ];
    }
}
